//
//  ViewController.m
//  谓词的使用
//
//  Created by unisedu on 16/1/11.
//  Copyright © 2016年 CaoFei. All rights reserved.
//

#import "ViewController.h"
#import "ZLPersonModel.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    ZLPersonModel *sunnyzl = [ZLPersonModel personWithName:@"sunnyzl" age:29 sex:ZLPersonSexMale];
    ZLPersonModel *jack = [ZLPersonModel personWithName:@"jack" age:22 sex:ZLPersonSexMale];
    //  首先我们来看一些简单的使用
    //  1.判断姓名是否是以s开头的
    NSPredicate *pred1 = [NSPredicate predicateWithFormat:@"name LIKE 's*'"];
    //  输出为：sunnyzl:1, jack:0
    NSLog(@"sunnyzl:%d, jack:%d", [pred1 evaluateWithObject:sunnyzl], [pred1 evaluateWithObject:jack]);
    //  2.判断年龄是否大于25
    NSPredicate *pred2 = [NSPredicate predicateWithFormat:@"age > 25"];
    //  输出为：sunnyzl的年龄是否大于25：1, jack的年龄是否大于25：0
    NSLog(@"sunnyzl的年龄是否大于25：%d, jack的年龄是否大于25：%d", [pred2 evaluateWithObject:sunnyzl], [pred2 evaluateWithObject:jack]);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
